﻿@using Telerik.Web.Mvc.UI;
@using Helena.Areas.Ventas.Models;
@using Helena.Areas.Configuraciones.Models;

@model Helena.Areas.Ventas.Models.VentaView


@{
    ViewBag.Title = "Anular Venta";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@Html.Telerik().ScriptRegistrar().Globalization(true)

<h2>Anular un comprobante de Pago</h2>
@using (Html.BeginForm())
{
    <fieldset>
        <legend>Busqueda</legend>
            <table style="width:100%">
                <tr>
                    <td>
                        <div class="editor-label"><b>Fecha</b></div>
                        <div class="editor-field">@Html.Telerik().AutoCompleteFor(m => m.Fecha)@Html.ValidationMessageFor(m => m.Fecha)</div>
                    </td>
                    <td>
                        <div class="editor-label"><b>Buscar por Nro Ticket</b></div>
                        <div class="editor-field">@Html.Telerik().AutoCompleteFor(m => m.Ticket)@Html.ValidationMessageFor(m => m.Ticket)</div>
                    </td>
                    <td>
                        <div class="editor-label"><b>Buscar por Nro Boleta</b></div>
                        <div class="editor-field">@Html.Telerik().AutoCompleteFor(m => m.Boleta)@Html.ValidationMessageFor(m => m.Boleta)</div>
                    </td>
                    <td>
                        <div class="editor-label"><b>Buscar por Nro Factura</b></div>
                        <div class="editor-field">@Html.Telerik().AutoCompleteFor(m => m.Factura)@Html.ValidationMessageFor(m => m.Factura)</div>
                    </td>
                    <td>
                            <input type="submit" value="Buscar" />
                    </td>
                </tr>
            </table>
    </fieldset>
<fieldset>        
<legend>Motivo</legend>
    <div class="editor-label"><b>Motivo por el cual Anula dicha venta</b></div>
    <div class="editor-field">@Html.Telerik().AutoCompleteFor(m => m.Descripcion)@Html.ValidationMessageFor(m => m.Descripcion)</div>
    <div class="editor-label"><b>Estado de la Venta</b></div>
    <div class="editor-field">@Html.CheckBoxFor(m => m.Estado)@Html.ValidationMessageFor(m => m.Estado)</div>
    
    

</fieldset>        
<fieldset>        
<legend>Resumen</legend>
                @if (ViewData["DetalleVenta"] != null)
                {
                @(Html.Telerik().Grid((ICollection<DetalleVentaView>)ViewData["DetalleVenta"])
                        .Name("DetalleVenta")
                        .DataKeys(keys => keys.Add(o => o.ID))
                        .Columns(columns =>
                        {
                            columns.ForeignKey(c => c.ProductoID, (System.Collections.IEnumerable)Session["Productos"], "ID", "Descripcion").Width(300);
                            columns.ForeignKey(c => c.UnidadID, (System.Collections.IEnumerable)Session["Unidades"], "ID", "Descripcion").Width(90);
                            columns.Bound(c => c.Cantidad).Width(80);
                            columns.Bound(c => c.PrecioU).Width(80);
                            columns.Bound(c => c.Subtotal).Width(80);
                        })
                            .DataBinding(dataBinding => dataBinding
                            .Ajax()
                            .Select("Select", "Anular")
                            )
                            .Pageable()
                            .Sortable()
                    ) 
                }
</fieldset>    
    
    <fieldset>
        <legend>Resumen de la Venta</legend>
            <table style="width:100%">
                <tr>
                    <td>
                        <table>
                            <tr>
                                <th>@Html.LabelFor(model => model.Descuento)</th>
                                <td>@Html.DisplayFor(m => m.Descuento)<b> %</b></td>
                            </tr>
                            <tr>
                                <th>@Html.LabelFor(model => model.Valor_Del_Igv_En_Soles)</th>
                                <td><b>S/.</b>@Html.DisplayFor(m => m.Valor_Del_Igv_En_Soles)</td>
                            </tr>
                            <tr>
                                <th>@Html.LabelFor(model => model.Sub_Total)</th>
                                <td><b>S/.</b>@Html.DisplayFor(m => m.Sub_Total)</td>
                            </tr>
                            <tr>
                                <th>@Html.LabelFor(model => model.Total_En_Soles)</th>
                                <td><b>S/.</b>@Html.DisplayFor(m => m.Total_En_Soles)</td>
                            </tr>
                            <tr>
                                <th>Vuelto</th>
                               <td><b>S/.</b>@Html.DisplayFor(m => m.Vuelto)</td>
                            </tr>
                        </table>
                    </td>
                    <td>
                        <table>
                            <tr>
                                <th>@Html.LabelFor(model => model.Pago_en_Efectivo_en_Soles)</th>
                                <td><b>S/.</b>@Html.DisplayFor(m => m.Pago_en_Efectivo_en_Soles)</td>
                            </tr>
                            <tr>
                                <th>@Html.LabelFor(model => model.Pago_en_Efectivo_en_Dolares)</th>
                                <td><b>US$/.</b>@Html.DisplayFor(m => m.Pago_en_Efectivo_en_Dolares)</td>
                            </tr>
                            <tr>
                                <th>@Html.LabelFor(model => model.Pago_con_Tarjeta_en_Soles)</th>
                                <td><b>S/.</b>@Html.DisplayFor(m => m.Pago_con_Tarjeta_en_Soles)</td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>

    </fieldset>

                if (ViewData["DetalleVenta"] != null)
                { 
    <table style="width:20%"> 
        <tr> 
            <td style="background-color: #CCFF99; color: #808080; font-weight: bold; font-size: 20px; border-style: ridge">
            <@Html.ActionLink("Anular", "Anular", "Anular", null)>
            </td>
        </tr>
    </table>
}
}
